package com.cci.kangdao.wechatOrder.model.wx;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

/**
 * 推送消息模板内容
 */
public class PushMessage {
    private String touser;
    private String template_id;
    private String url;
    private Map<String,Map<String,String>> data = new HashMap<>();

    public void setData(MessageData md){
      Field[] fields = md.getClass().getDeclaredFields();
        for (Field field:fields) {
            field.setAccessible(true);
            String name =  field.getName();
            Map<String,String>  body =  new HashMap<>();
            try{
                Object value = field.get(md);
                if (value !=null){
                    body.put("value",value.toString());
                    data.put(name,body);
                }
            }
            catch (Exception e){
                e.printStackTrace();
            }

        }

    }

    public String getTouser() {
        return touser;
    }

    public void setTouser(String touser) {
        this.touser = touser;
    }

    public String getTemplate_id() {
        return template_id;
    }

    public void setTemplate_id(String template_id) {
        this.template_id = template_id;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public Map<String, Map<String, String>> getData() {
        return data;
    }

}
